package org.myself.meeting.service;

import org.myself.meeting.Utils.Constant;
import org.myself.meeting.mapper.ChatsMapper;
import org.myself.meeting.model.Chats;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ChatsService {

    @Autowired
    ChatsMapper chatsMapper;

    public Integer addChats(Chats chats) {
        return chatsMapper.addChats(chats);
    }

    public List<Chats> getAllChat() {
        Integer page = chatsMapper.getALLChatNUM();
        if (page > Constant.CHATSNUMS){
            return chatsMapper.getAllChat(page-Constant.CHATSNUMS,Constant.CHATSNUMS);
        }else{
            return chatsMapper.getAllChatNoParam();
        }
    }
    public List<Chats> getAllChat(Integer page) {
        page = (page-1)*80;
        return chatsMapper.getAllChat(page,Constant.CHATSNUMS);

    }
}
